Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
Gitlab Coverage Badge Shows "Unknown" - NodeJS with Jest

Im having an issue where my gitlab coverage badge reports back as "unknown" for a NodeJS project Im working. Ive read through dozens of stackoverflow articles about this and tried all the suggested solutions to no avail, so I figured I would put the specifics of my setup in this post to see if anyone can pinpoint what might be causing the issue.

The job I have in my gitlab-ci.yml file is as follows:

 test_coverage:
  image: node:16
  stage: test_coverage
  before_script:
    - echo "This skips any predefined before scripts to ensure clean environments"
  tags:
    - Nexus
  script:
    - npm run test:ci
  coverage: /All\sfiles.*?\s+(\d+.\d+)/
  artifacts:
    when: always
    reports:
        junit:
            - ./junit.xml
        cobertura: coverage/cobertura-coverage.xml
  dependencies:
    - install
  except:
    - tags

The script npm run test:ci in my package.json files is as follows:

"test:ci": "CI=true NODE_ENV=test ENVIRONMENT=CI_CD NODE_OPTIONS=--experimental-vm-modules jest --coverage --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporter=html --reporter=text --reporter=cobertura --reporters=default --reporters=jest-junit --watchAll=false"

I've got the following regex in the test coverage reporting settings section of gitlab

/All\sfiles.*?\s+(\d+.\d+)/

I have the badge link and URL set up as well in gitlab.

When I run my npm run test:ci script locally, I get a lovely coverage report returned. When my job runs in the gitlab pipeline, my coverage report has 0 for every file. It tells me all my tests ran and passed. It tells me that my junit and cobertura artifacts were successfully completed, and that the job succeeded.

I have a strong feeling that if I were seeing actual coverage numbers in the gitlab job logs like I see when I run the script locally, the badge would work. But I have no ideas why I'm getting all 0s reported. Can anyone see what Im doing wrong based on the info provided here?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!